<?php get_instance()->view('common/header');?>
<link href="<?php echo $this->staticUrl?>video/css/video-js.min.css" rel="stylesheet" type="text/css">
<script src="<?php echo $this->staticUrl?>video/js/video.min.js"></script>
<style>
.huifuimgbox{height:auto;}
.huifuimgbox .imgbox{width:30%;margin-bottom:0.5em;}
</style>
<body>
<div class="chuizhi p10_0 pt30" style="background: url('<?php echo $this->staticUrl?>img/jpg/pic19.jpg') no-repeat;background-size: 100%;  background-attachment:fixed;  background-position-y: -2em;">
    <div class="maxuserimg"><img src="<?php echo $user['userPortrait']?>" alt=""></div>
    <div class="m5_0"><b class="f12 dk tc lh10"><?php echo $user['userName']?></b><span class="f09 tc"><?php echo $user['userMobile']?></span></div>
</div>
<?php if ($type != 2):?>
    <div class="saixuan twosai">
        <a href="<?php echo getUrl('find?id='.$relationId)?>" class=""><?php echo $titleFind?> （<?php echo $count['find']?>）</a>
        <?php if ($relationId == $this->userId):?>
        <a href="<?php echo getUrl('friendsCircle/myFriendsCircle?id='.$relationId)?>" class="actived"> 我的动态 （<?php echo $count['friends']?>）</a>
        <?php else:?>
            <a href="<?php echo getUrl('friendsCircle?id='.$relationId)?>" class="actived">  他的动态（<?php echo $count['friends']?>）</a>
        <?php endif;?>
        <div class="after"></div>
    </div>
<?php endif;?>
<?php if (!empty($list['list'])):?>
    <div class="list">
        <?php foreach ($list['list'] as $k => $v):?>
            <div class="bor_tt p3p">
                <div class="huifu">
                    <p class="m5_0 f09 heng righttimepd"><span class="dk"><?php echo $v['content']?></span>
                        <span class="f07 pjdatatime"><?php echo $v['addtime']?></span>
                    </p>
                    <?php if (!empty($v['image'])): ?>
                        <div class="huifuimgbox imgboxpull">
                            <?php foreach ($v['image'] as $kk => $vv):?>
                                <div class=" imgbox"><img src="<?php echo $vv['og']?>" alt=""></div>
                            <?php endforeach;?>
                        </div>
                    <?php  endif;?>
                    <?php if(!empty($v['video'])): ?>
                        <div class="imgbox">
                            <video
                                    class="video-js vjs-default-skin" controls preload="none" poster="<?php echo $v['coverUrl']?>" style="width:100%;height:100%;">
                                <source src="<?php echo $v['video']?>" type='video/mp4' />
                            </video>
                        </div>
                    <?php endif;?>
                    <div class="textEll f08 cor9 heng">
                        <div>浏览<?php echo $v['browse_number']?>次
                            <a href="" class="cor9 ml10"><?php echo $v['address']?></a>
                        </div>
                        <div class="vCenter f12">
                            <a href="javascript:;" class="mr10 praise" data-id="<?php echo $v['id']?>">
                                <?php if ($v['praise'] == 1):?>
                                    <img src="<?php echo $this->staticUrl?>img/png/pic88.png" class="heightimg" alt="">
                                <?php else:?>
                                    <img src="<?php echo $this->staticUrl?>img/png/pic87.png" class="heightimg" alt="">
                                <?php endif;?>
                            </a>
                            <a href="<?php echo getUrl('friendsCircle/details?fid='.$v['id'].'&type='.$type)?>" class="mr10">
                                <img class="heightimg" src="<?php echo $this->staticUrl?>img/png/pic103.png" alt="">
                            </a>
                            <?php if ($isMe):?>
                                <div href="<?php echo getUrl('friendsCircle/deleteFriendsCircle?fid='.$v['id'])?>" class="ajax-request-btn" alert-message="是否确认删除？">
                                    <img class="heightimg" src="<?php echo $this->staticUrl?>img/png/pic137.png" alt="">
                                </div>
                            <?php endif;?>
                        </div>
                    </div>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
    <div class="weui-loadmore" style="display: none">
        <div class="load">
            <i class="weui-loading"></i>
            <span class="weui-loadmore__tips">正在加载</span>
        </div>
        <span class="noC" style="display: none">没有更多内容了~</span>
    </div>
<?php else:?>
    <div class="statebox chuizhi jdjz" style="flex: 1;height: 63%;">
        <img class="stateimgda mb5" src="<?php echo $this->staticUrl?>img/default/2.png" alt="">
        <?php if ($isMe):?>
            <span class="f09 cor9 tc mb20">主人，您还没有发布动态哦~</span>
            <a href="<?php echo getUrl('friendsCircle/add')?>" class="daborbtnPub mb10 f12">去发布</a>
        <?php else:?>
            <span class="f09 cor9 tc mb20">暂无数据</span>
        <?php endif;?>
    </div>
<?php endif;?>
</body>
<script src="<?php echo $this->staticUrl?>js/jquery-weui.js"></script>
<script src="<?php echo $this->staticUrl?>js/base.js"></script>
<script type="text/javascript">
    $(function () {
        /**
         * 点赞
         */
        $(".list").delegate('.praise', 'click', function () {
            blockUI.show();
            var id = $(this).attr('data-id'),
                praise_image,
                type = "<?php echo $type?>",
                _this = $(this);
            $.ajax('<?php echo getUrl('friendsCircle/praise');?>', {
                dataType:'json',
                type:'post',
                data:{fid:id,type:type},
                error:function(){
                    blockUI.hide();
                    show_message({status:0, message:'请求超时'});
                },
                timeout:60000,
                success:function(e,textStatus,jqXHR){
                    blockUI.hide();
                    show_message(e);
                    if (e.status == 1) {
                        if (e.data.status == 1){
                            // 未点赞
                            praise_image = '<?php echo $this->staticUrl?>img/png/pic87.png';
                        }else{
                            // 已点赞
                            praise_image = '<?php echo $this->staticUrl?>img/png/pic88.png';
                        }
                        _this.find('img').attr('src', praise_image);
                    }
                }
            });
        });

        /**
         * 上拉加载数据
         */
        var page = "<?php echo $list['page']?>",
            relationId = "<?php echo $relationId?>",
            isMe = "<?php echo $isMe?>",
            type = "<?php echo $type?>";
        var loading = false;  //状态标记
        $(document.body).infinite().on("infinite", function() {
            if(loading) return;
            loading = true;
            $(".weui-loadmore").show();
            $(".load").show();
            $(".noC").hide();
            // $(document.body).destroyInfinite() // 销毁插件
            // $(document.body).infinite() // 重新初始化
            $.ajax('<?php echo getUrl('friendsCircle/getList');?>', {
                type:'post',
                data:{page:page,type:1,relationId:relationId},
                dataType:'json',
                error:function(){
                    show_message({status:0, message:'请求超时'});
                },
                timeout:60000,
                success:function(e){
                    loading = false;
                    if (!e.data.list.length){
                        $(document.body).destroyInfinite();
                        $(".load").hide();
                        $(".noC").show();
                        return;
                    }
                    page = e.data.page;
                    $(".weui-loadmore").hide();
                    var html,
                        detailsImg = "<?php echo $this->staticUrl?>img/png/pic103.png",
                        deleteImg = "<?php echo $this->staticUrl?>img/png/pic137.png";
                    $.each(e.data.list, function (key, obj) {
                        var image = '',praise,
                            detailsUrl = "<?php echo getUrl('friendsCircle/details?type=')?>"+type+'&fid='+obj.id,
                            deleteUrl = "<?php echo getUrl('friendsCircle/deleteFriendsCircle?fid=')?>"+'?fid='+obj.id,
                            deleteHtml = '';
                        if (obj.image.length){
                            image = '<div class="huifuimgbox imgboxpull">';
                            $.each(obj.image,function (k, v) {
                                image += '<div class=" imgbox"><img src="'+v.og+'" alt=""></div>';
                            });
                            image += '</div>';
                        }

                        if (obj.praise == 1){
                            praise = '<img src="<?php echo $this->staticUrl?>img/png/pic88.png" class="heightimg" alt="">';
                        }else{
                            praise = '<img src="<?php echo $this->staticUrl?>img/png/pic87.png" class="heightimg" alt="">';
                        }
                        if (isMe){
                            deleteHtml = '<a href="'+deleteUrl+'" class="ajax-request-btn" alert-message="是否确认删除？">' +
                                '<img class="heightimg" src="'+deleteImg+'" alt="">' +
                                '</a>';
                        }
                        html =
                            '<div class="bor_tt p3p">'+
                                '<div class="huifu">'+
                                    '<p class="m5_0 f09 heng righttimepd">'+
                                        '<span class="dk">'+obj.content+'</span>'+
                                        '<span class="f07 pjdatatime">'+obj.addtime+'</span>'+
                                    '</p>'+image+
                                    '<div class="textEll f08 cor9 heng">'+
                                        '<div>浏览'+obj.browse_number+'次' +
                                            '<a href="" class="cor9 ml10">'+obj.address+'</a>' +
                                        '</div>' +
                                        '<div class="vCenter f12">' +
                                            '<a href="javascript:;" class="mr10 praise" data-id="'+obj.id+'">'+praise+'</a>' +
                                            '<a href="'+detailsUrl+'" class="mr10">' +
                                                '<img class="heightimg" src="'+detailsImg+'" alt="">' +
                                            '</a>' +deleteHtml+
                                        '</div>' +
                                    '</div>'+
                                '</div>'+
                            '</div>';
                        $(".list").append(html);
                    });
                }
            });
        });
    })
</script>
</html>